package com.bdqn.ch07.mapper.impl;

import com.bdqn.ch07.mapper.SysRoleMapper;
import com.bdqn.ch07.pojo.SysRole;
import org.mybatis.spring.SqlSessionTemplate;

import java.util.List;

/**
 * SysRoleMapperImpl
 *
 * @aurhor Administrator  whs
 * @since 2024/7/22
 */
public class SysRoleMapperImpl implements SysRoleMapper {

    /**
     *  通过 SqlSessionTemplate 操作数据库
     */

    private SqlSessionTemplate sqlSession;

    /**
     * ch07 简答
     * 实现角色信息的添加操作
     *
     * @param sysRole
     * @return
     */
    @Override
    public List<SysRole> addSysRole(SysRole sysRole) {
        return sqlSession.getMapper(SysRoleMapper.class).selectSysRoleByRoleName(sysRole);
    }

    /**
     * ch07 简答
     * 根据角色名称模糊查询角色列表的操作
     *
     * @param
     * @return
     */
    @Override
    public List<SysRole> selectSysRoleByRoleName(SysRole sysRole) {
        return sqlSession.getMapper(SysRoleMapper.class).addSysRole(sysRole);
    }

    public SqlSessionTemplate getSqlSession() {
        return sqlSession;
    }

    public void setSqlSession(SqlSessionTemplate sqlSession) {
        this.sqlSession = sqlSession;
    }
}
